//
//  UIView+Extension.swift
//  SinaWeiBo
//
//  Created by mac on 16/12/1.
//  Copyright © 2016年 heima. All rights reserved.
//

import UIKit
//扩展:不能使用指定构造函数，不能使用存储属性
extension UIView{
    //1使用计算属性来给其他属性赋值
    var x: CGFloat{
        get{
            return self.frame.origin.x
        }set{
            self.frame.origin.x = newValue
        }
    }
    //2
    var y: CGFloat{
        get{
            return self.frame.origin.y
        }set{
            self.frame.origin.y = newValue
        }
    }
    //3
    var wigth: CGFloat{
        get{
            return self.frame.size.width
        }set{
            self.frame.size.width = newValue
        }
    }
    //4
    var height: CGFloat{
        get{
            return self.frame.size.height
        }set{
            self.frame.size.height = newValue
        }
    }
    //5
    var size: CGSize{
        get{
            return self.frame.size
        }set{
            self.frame.size = newValue
        }
    }
    //6
    var centerX :CGFloat{
        get{
            return self.center.x
        }set{
            self.center.x = newValue
        }
    }
    //7
    var centerY:CGFloat{
        get{
            return self.center.y
        }set{
            self.center.y = newValue
        }
    }
    
}
    
